package decorator.stream;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

// Java 装饰器的例子：FilterInputStream
// 如：BufferedInputStream, LineNumberInput 等

public class Test {

	public static void main(String[] args) {
		try {
			InputStream in = new BufferedInputStream(new FileInputStream("test.txt"));
			int c;
			while((c=in.read()) >=0) {
				System.out.print((char)c);
			}
			
			in.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
